package com.tools.common.aop.track;

import android.util.Log;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;

@Aspect
public class TrackAspect {
    @Pointcut("execution(@com.tools.common.aop.track.Track * *..*.*(..))")
    public void pcTrackPoint() {
    }

    @Around("pcTrackPoint()")
    public void methodTrackPoint(ProceedingJoinPoint joinPoint) {
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
//        Method method = methodSignature.getMethod();
//        String methodName = method.getName();
        String methodDesc = methodSignature.toShortString();

        Log.d("TrackAspect", "before " + methodDesc);

        try {
            joinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }

        Log.d("TrackAspect", "after " + methodDesc);
    }

}